package middleware

import (
	"geek-cloud-native/chapter04-0925/global"
	"github.com/julienschmidt/httprouter"
	"net/http"
)

func HeaderMiddleware(router httprouter.Handle) httprouter.Handle {
	return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
		token := r.Header.Get("token")
		w.Header().Set("token", token)
		w.Header().Set("version", global.ServerSetting.Version)
		router(w, r, ps)
	}
}
